package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingEventInfo;
import com.ruoyi.ring.service.IRingEventInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 活动信息
 * 
 * @author liuwp
 * @date 2025-08-28
 */
@RestController
@RequestMapping("/ring/ring_event_info")
public class RingEventInfoController extends BaseController
{
    @Autowired
    private IRingEventInfoService ringEventInfoService;

    /**
     * 查询活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_event_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingEventInfo ringEventInfo)
    {
        startPage();
        List<RingEventInfo> list = ringEventInfoService.selectRingEventInfoList(ringEventInfo);
        return getDataTable(list);
    }

    /**
     * 导出活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_event_info:export')")
    @Log(title = "活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingEventInfo ringEventInfo)
    {
        List<RingEventInfo> list = ringEventInfoService.selectRingEventInfoList(ringEventInfo);
        ExcelUtil<RingEventInfo> util = new ExcelUtil<RingEventInfo>(RingEventInfo.class);
        util.exportExcel(response, list, "活动信息数据");
    }

    /**
     * 获取活动信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_event_info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringEventInfoService.selectRingEventInfoById(id));
    }

    /**
     * 新增活动信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_event_info:add')")
    @Log(title = "活动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingEventInfo ringEventInfo)
    {
        return toAjax(ringEventInfoService.insertRingEventInfo(ringEventInfo));
    }

    /**
     * 修改活动信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_event_info:edit')")
    @Log(title = "活动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingEventInfo ringEventInfo)
    {
        return toAjax(ringEventInfoService.updateRingEventInfo(ringEventInfo));
    }

    /**
     * 删除活动信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_event_info:remove')")
    @Log(title = "活动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringEventInfoService.deleteRingEventInfoByIds(ids));
    }

}
